package com.bjpowernode.controller;

import com.bjpowernode.model.Result;
import com.bjpowernode.domain.Items;
import com.bjpowernode.service.ItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "商品管理接口")
public class ItemController {
    @Resource
    private ItemsService itemsService;

    /***
     * 这个接口需要公用,
     * 查询热门商品:卖的比较多
     * 查询推荐商品:是否被推荐
     * @param city 城市
     * @param type 区分是否被推荐
     * @return
     */
    @GetMapping("hotProductOrRecommendation")
    @ApiOperation("查询热门商品或推荐商品")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "城市", value = "city", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "类型", value = "type", dataType = "Integer", paramType = "query")
            })
    public Result<List<Items>> getHotProductOrRecommendation(String city, Integer type) {
        List<Items> itemsList = itemsService.findHotProductOrRecommendation(city, type);
        return Result.success("ok", itemsList);
    }
}
